package com.ruoyi.task.controller;


import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;

import org.springframework.web.bind.annotation.RequestMapping;

@RequestMapping("/task/task")
public class EmailSendController {

    @Autowired
    public JavaMailSender javaMailSender;// 从容器中拿到 邮件发送对象



    @RequestMapping("/email")
    public String send(){
        SimpleMailMessage mailMessage = new SimpleMailMessage();
        //设置发送人
        mailMessage.setFrom("794755302@qq.com");
        //邮件主题
        mailMessage.setSubject("新型冠状病毒防护指南");
        //邮件内容：普通文件无法解析html标签
        mailMessage.setText("<h1>好好在家待着.....</h1>");
        //收件人
        mailMessage.setTo("227859882@qq.com");
        //发送邮件
        javaMailSender.send(mailMessage);

        return "邮件发送成功";


    }

}
